<!doctype html>
<!-- Import from a ES Module CDN -->
<script type="module">
    import { loadQuickJs } from "https://esm.sh/@sebastianwessel/quickjs@3.0.0";
    import variant from "https://esm.sh/@jitl/quickjs-wasmfile-release-sync";

    const { runSandboxed } = await loadQuickJs(variant);

    const options = {
        allowFetch: true, // inject fetch and allow the code to fetch data
        allowFs: true, // mount a virtual file system and provide node:fs module
        env: {
            MY_ENV_VAR: "env var value",
        },
    };

    const result = await runSandboxed(async ({ evalCode }) => {
        return await evalCode("export default 1+1");
    }, options);

    console.log(result);
</script>
